package com.iss.okair.controller.baseinfo;

import com.iss.okair.db.entity.Category;
import com.iss.okair.db.entity.CategoryParent;
import com.iss.okair.service.baseinfo.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
//导入头部地址
@RequestMapping("logic/baseInfo/category")
public class CategoryController {

    @Autowired
    private CategoryService service;

    @RequestMapping("/parentList")
    public List<CategoryParent> getCategorylist(){
        return service.parentList();
    }

    @RequestMapping("/find")
    public List<Category> find(Category example){
        return service.findByExample(example);
    }

    @RequestMapping("/list/{parentId}")
    public List<Category> ListByParentId(@PathVariable int parentId){
        return service.findByParentId(parentId);
    }
    @RequestMapping("{id}")
    public Category listupdate(@PathVariable int id){
      return service.findId(id);
    }

    //优化做法 在类都能存在的情况下



}